package model;

import java.util.Date;
import java.util.UUID;

/**
 * This class represents a Criterion used for cases evaluation in different business cases. 
 * @author Raphael Rodrigues
 *
 */
public class Criterion implements Comparable<Criterion>
{
	private UUID ID;
	private double weight;
	private String goal;
	private String name;
	private String reference;
	private String description;
	private String solutionImpact;
	private Date createdDate;
	private Date lastUpdated;
	
	private Process relatedProcess;
	
	public Criterion()
	{
		ID = UUID.randomUUID();
		createdDate = new Date();
		lastUpdated = new Date();
	}
	
	public Criterion(String name, UUID ID)
	{
		this.ID = ID;
		setName(name);
		createdDate = new Date();
		lastUpdated = new Date();
	}
	
	/**
	 * Returns the weight of the current Criterion, which is used to measure the relevance of this criterion in the evaluation.
	 * @return Criterion Weight
	 */
	public double getWeight() {
		return weight;
	}
	
	/**
	 * Sets the weight for the current criterion
	 * @param weight
	 */
	public void setWeight(double weight) {
		this.weight = weight;
	}

	/**
	 * Gets the goal that the current criterion.
	 * @return Criterion goal
	 */
	public String getGoal() {
		return goal;
	}
	
	public void setGoal(String goal) {
		this.goal = goal;
	}
	
	/**
	 * Returns the ID for the current Criterion
	 * @return Criterion's ID
	 */
	public UUID getID() {
		return ID;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getReference() {
		return reference;
	}
	
	public void setReference(String reference) {
		this.reference = reference;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getSolutionImpact() {
		return solutionImpact;
	}
	
	public void setSolutionImpact(String solutionImpact) {
		this.solutionImpact = solutionImpact;
	}

	public Process getRelatedProcess() {
		return relatedProcess;
	}
	
	public void setRelatedProcess(Process relatedProcess) {
		this.relatedProcess = relatedProcess;
	}
	
	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	
	@Override
	public boolean equals(Object obj) 
	{
		boolean equals = false;
		
		if(obj.getClass() == this.getClass())
			equals = (ID.equals(((Criterion)obj).getID()));
		
		return equals;
			
	}
	
	@Override
	public int hashCode() 
	{
		return ID.hashCode();
	}
	
	@Override
	public int compareTo(Criterion other) 
	{
		return name.compareToIgnoreCase(other.getName());
	}
}
